// 用来造home页面的数据的
import Mock from 'mockjs';
// import { param2Obj } from '../utils/urlUtis'


// 生成概况信息数据
var summarylist = [
    {
        // number: Mock.mock('@natural(30, 66)'),
        number: 48,
        theme: "今日参加活动人次",
    },
    {
        // number: Mock.mock('@float(2000, 6000, 0, 2)'),
        number: 3121.20,
        theme: "今日活动收入",
    },
    {
        // number: Mock.mock('@natural(200, 2000)'),
        number: 1976,
        theme: "今日课程订单数",
    },
    {
        // number: Mock.mock('@float(15000, 22000, 0, 2)'),
        number: 19782.61,
        theme: "今日课程订单收入",
    },
];
// 每触发一次函数，number随机增加
function setSummaryData() {
    summarylist.forEach((item, index) => {
        if (index == 0 || index == 2) {
            item.number += Mock.mock('@natural(1, 10)');
        } else {
            item.number += Mock.mock('@float(100, 500, 0, 2)');
        }
    })
}



// 生成学员信息数据
var studentlist = [];
for (var i = 0; i < 99; i++) {
    var item = Mock.mock({
        'rank': '@increment',
        'name': '@cname',
        'phone': /1[3-9]\d{9}/,
        'spend|100-3000.0-2': 1,
        'level': '@natural(1, 5)',
    });
    item.spend = item.spend.toFixed(2);
    studentlist.push(item)
}


// 生成课程信息数据
// var classlist = [];
// for (var i = 0; i < 20; i++) {
//     var item = Mock.mock({
//         'id': '@natural(1, 10)',
//         'imgurl': Mock.Random.image('80x60', Mock.mock('@color'), '#FFF', 'png', 'class'),
//         'classname1': '@cword(3, 7)',
//         'teacher': '@cname()',
//         'price|399-2999': 1,
//     })
//     item.price = item.price.toFixed(2);
//     classlist.push(item);
// }
//  图片地址： require("@/assets/HomeViewImages/class/kecheng-picture01.png")
var classlist = [];
for (var i = 1; i < 9; i++) {
    // var str =`@/assets/HomeViewImages/class/kecheng-picture0${num}.png`;
    var item = Mock.mock({
        'id': '@natural(1, 8)',
        'imgurl': require(`@/assets/HomeViewImages/class/kecheng-picture0${i}.png`),
        'classname|1': ['HTML5大前端', 'JAVA开发', 'Python数据分析', '云计算', '全栈软件测试', '大数据', '智能互联网', '网络安全', '认证考试', '区块链'],
        'teacher|1': ['小飞侠', '王露纯', '雷承徳', 'Kerwin', '前端小灰狼', '陈丽', '江磊', '刘鹏'],
        'price|1599-29999': 1,
    })
    item.price = item.price.toFixed(2);
    classlist.push(item);
}


// 生成教师信息
// var steacherlist = [];
// for (var i = 0; i < 20; i++) {
//     var item = Mock.mock({
//         'id': '@id',
//         'iconurl': Mock.Random.image('50x50', Mock.mock('@color'), '#FFF', 'png', 'icon'),
//         'teachername|1': ['@first', '@cname()'],
//         'uploadperson|1': ['Amy', 'Jason', 'James'],
//     })
//     var type = (/[a-zA-Z]/.test(item.teachername)) ? Mock.mock({ "intro|1": ["英语外教", "法语外教", "德语外教"] }) : Mock.mock({ "intro|1": ["物理教师", "数学教师", "英语教师"] });
//     item.intro = type.intro;
//     steacherlist.push(item);
// }
var steacherlist = [
    {
        iconurl: '	http://www.mobiletrain.org/2021/1229/1640768668613.png',
        teachername: '小飞侠',
        intro: '三阶段讲师',
        uploadperson: 'panpan'
    },
    {
        iconurl: 'http://upload.mobiletrain.org/2019/0910/1568103659362.png',
        teachername: '王露纯',
        intro: '二阶段讲师',
        uploadperson: 'shiyu'
    }, {
        iconurl: 'http://upload.mobiletrain.org/2018/0731/1532999796370.jpg',
        teachername: '雷承徳',
        intro: '三阶段讲师',
        uploadperson: 'yaxin'
    }, {
        iconurl: '	http://www.mobiletrain.org/2022/0418/1650267844594.png',
        teachername: 'Kerwin',
        intro: '二阶段讲师',
        uploadperson: 'dandan'
    }, {
        iconurl: 'http://www.mobiletrain.org/2021/1229/1640763507955.png',
        teachername: '前端小灰狼',
        intro: '二阶段讲师',
        uploadperson: 'zhongge'
    }, {
        iconurl: 'http://upload.mobiletrain.org/2019/0910/1568102394254.png',
        teachername: '陈丽',
        intro: 'HTML5讲师',
        uploadperson: 'chaoge'
    }, {
        iconurl: 'http://upload.mobiletrain.org/2019/0620/1561016111211.jpg',
        teachername: '江磊',
        intro: 'Java讲师',
        uploadperson: 'lijian'
    }, {
        iconurl: 'http://upload.mobiletrain.org/2018/0731/1533000108266.jpg',
        teachername: '刘鹏',
        intro: 'HTML5讲师',
        uploadperson: 'wangcaibo'
    },
];

// 生成教育头条信息
var newslist = [
    {
        date: Mock.mock('@datetime'),
        imgurl: require("@/assets/HomeViewImages/news/edu1.jpg"),
        // imgurl: Mock.Random.image('80x60', Mock.mock('@color'), '#FFF', 'png', 'news'),
        title: "教育部部署做好2022年中小学暑期有关工作",
        describe: "据教育部网站消息，暑假即将来临，为使广大中小学生度过一个平安、健康、快乐、有意义的暑假，日前，教育部办公厅印发《关于做好2022年中小学暑期有关工作的通知》，部署做好相关工作。",
    },
    {
        date: Mock.mock('@datetime'),
        imgurl: require("@/assets/HomeViewImages/news/edu2.jpg"),
        // imgurl: Mock.Random.image('80x60', Mock.mock('@color'), '#FFF', 'png', 'news'),
        title: `2022高招季 院士帮你“选”专业`,
        describe: "大学专业怎么选，院士帮你来支招！11位院士轮番登场，为考生及家长提供权威的专业解读，供考生及家长进行有针对性的参考。",
    },
    {
        date: Mock.mock('@datetime'),
        imgurl: require("@/assets/HomeViewImages/news/edu3.jpg"),
        // imgurl: Mock.Random.image('80x60', Mock.mock('@color'), '#FFF', 'png', 'news'),
        title: `教育部强调暑期校园防控不得过度防控层层加码`,
        describe: "教育部应对新冠肺炎疫情工作领导小组日前印发通知，就2022年暑期教育系统疫情防控工作作出部署。",
    },
    {
        date: Mock.mock('@datetime'),
        imgurl: require("@/assets/HomeViewImages/news/edu4.jpg"),
        // imgurl: Mock.Random.image('80x60', Mock.mock('@color'), '#FFF', 'png', 'news'),
        title: `留学推荐信 写好有诀窍`,
        describe: "如何选择合适的推荐人？准备推荐信时又有哪些注意事项？让我们听听过来人和留学申请专家怎么说。",
    },
    {
        date: Mock.mock('@datetime'),
        imgurl: require("@/assets/HomeViewImages/news/edu5.jpg"),
        // imgurl: Mock.Random.image('80x60', Mock.mock('@color'), '#FFF', 'png', 'news'),
        title: `“特岗教师”上热搜，6.7万招聘计划带来哪些利好？`,
        describe: "近日，2022年义务教育阶段中央“特岗计划”招聘工作启动，全国计划招聘特岗教师6.7万人，“特岗教师”的话题也随之冲上网络热搜榜。“特岗教师”是什么？乡村教育如何让人才招得来、留得住、能扎根？",
    },
];

// 生成待办信息
// var todoObj = {
//     topay: 15,
//     paid: 45,
//     toconfirm: 12,
//     confirmed: 30,
//     toreply: 40,
//     replied: 40,
// }
// 每触发一次函数，随机一次
var todoObj = [];
function setTodoData() {
    todoObj = Mock.mock({
        'topay': '@natural(100,500)',
        'paid': '@natural(100,500)',
        'toconfirm': '@natural(100,500)',
        'confirmed': '@natural(100,500)',
        'toreply': '@natural(100,500)',
        'replied': '@natural(100,500)',
    })
}


// 调用接口方法
export default {
    getSummaryData() {
        setSummaryData();
        return {
            code: 200,
            msg: '请求成功',
            data: summarylist,
            total: summarylist.length
        }
    },
    getStudentData() {
        return {
            code: 200,
            msg: '请求成功',
            data: studentlist,
            total: studentlist.length
        }
    },
    getClassData() {
        return {
            code: 200,
            msg: '请求成功',
            data: classlist,
            total: classlist.length
        }
    },
    getTeacherData() {
        return {
            code: 200,
            msg: '请求成功',
            data: steacherlist,
            total: steacherlist.length
        }
    },
    getEduNewsData() {
        return {
            code: 200,
            msg: '请求成功',
            data: newslist,
            total: newslist.length
        }
    },
    getTodoDate() {
        setTodoData();
        return {
            code: 200,
            msg: '请求成功',
            data: todoObj,
            total: todoObj.length
        }
    }
}

